package stage.action;

import stage.factory.AppFactory;
import stage.manager.*;
import stage.pojo.NewcomeInfo;

import com.opensymphony.xwork2.ActionSupport;
/**
 * the action class for adding new data in the database. 
 * @author remi liu(Liu Zhibin)
 * @version 0.0
 */
public class AddAction extends ActionSupport{
	private static final long serialVersionUID = 1L;
	NewcomeInfo newcomeInfo;
	public NewcomeInfo getNewcomeInfo(){
		return this.newcomeInfo;
	}
	public void setNewcomeInfo(NewcomeInfo newcomeInfo){
		this.newcomeInfo=newcomeInfo;
	}
	public String add() throws Exception{
		System.out.println(newcomeInfo.getHospital());
		System.out.println(newcomeInfo.getDepartment());
		System.out.println(newcomeInfo.getIsExpert());
		System.out.println(newcomeInfo.getWeekOrdinal());
		System.out.println(newcomeInfo.getWeekday());
		System.out.println(newcomeInfo.getWeather());
		System.out.println(newcomeInfo.getNum());
		HistoricalInfoService hs=(HistoricalInfoService)AppFactory.instance().getApp("HistoricalInfoService");
		hs.save(ConvertInfo.toHistoricalInfo(newcomeInfo));
		System.out.println("保存成功");
		return SUCCESS;
	}
}
